
function main( ui ) {

  return getTransactions();

}


function getTransactions() {

  var records = new JSONArray();

  //var cmd = "select t from TransactionEntity t where t.type=:type and t.subType=:stype and t.longDate<:lday";
  
  //var d = new java.util.Date();
  //var filter = toMap({ type:'badge', stype:'out', lday:d.time});

  var cmd = "select t from EventEntity t";
   //var filter = new JSONObject("{ type:'badge', stype:'out', lid:27007}");
  //var cmd = "select t from TransactionEntity t where t.userId=:userId and t.type=:type and t.subType=:subType";
  //var cmd = "select t from TransactionEntity t where t.type=:type order by t.longDate";
  var filter = null;
  //var filter = new JSONObject("{ type:'badge', subType:'in', userId:'acasolla'}");
  //var filter = new JSONObject("{ type:'badge', userId:'acasolla'}");
  
    EntityManager.find(  
    cmd,  
    filter,
     function(result) {
      
      for( var i = 0; i < result.size() ; ++i ) {
        
        records.put( JSONObject.wrap(result.get(i)) );
      }
      
    });
    
    var result = new JSONObject();
    
    result.put( "records", records );
    

    return result.toString() ;

}

